package com.supereye.platform.web.org.dao;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.supereye.platform.base.BaseDao;
import com.supereye.platform.web.org.model.SysOrg;

@Repository
public class OrgDao extends BaseDao {
	public List<SysOrg> getOrgList(SysOrg org) throws Exception{
		return sqlSessionTemplate.selectList("com.supereye.platform.web.org.dao.OrgDao.querySysOrg",org);
	}

	public void addOrg(SysOrg org) throws Exception {
		sqlSessionTemplate.insert("com.supereye.platform.web.org.dao.OrgDao.addSysOrg", org);
	}

	public List<SysOrg> getOrgListWithParent(SysOrg org) throws Exception{
		return sqlSessionTemplate.selectList("com.supereye.platform.web.org.dao.OrgDao.querySysOrgWithParent", org);
	}

	public void deleteOrgs(String[] orgIds) throws Exception {
		List<Object[]> params = new ArrayList<Object[]>();
		for(String orgId:orgIds){
			params.add(new String[]{orgId});
		}
		jdbcTemplate.batchUpdate("delete from sys_org where id=?", params);
	}

	public void updateOrg(SysOrg org) throws Exception{
		 sqlSessionTemplate.update("com.supereye.platform.web.org.dao.OrgDao.updateSysOrg", org);
	}

}
